E:/E+I/Informatik/Projekte/FH/n-Damen Problem/chessboard.c File Reference

#include "ndame.h"

Go to the source code of this file.

Functions

void chessboard (struct data *d1)
 chessboard


Detailed Description

PURPOSE: file creates a visual chessbord on screen

Author:
Daniel Hasemann
Version:
1.0
Date:
December 16th, 2005

Definition in file chessboard.c.


Function Documentation

void chessboard struct data d1  ) 
 

chessboard

This function prints a chessboard on screen, which can change the size between MAX_SIZE x MAX_SIZE and MIN_SIZE x MIN_SIZE. There is a frame around the chessboard with a variable size. To identify every flied on the chessboard there are number and letter combinations from A1 (left lower position) to L12 (right upper position) around the board.

Parameters:
*d1 is a struct pointer
See also:
menu()

options()

Author:
Daniel Hasemann
Date:
December 16th, 2005

Definition at line 25 of file chessboard.c.

References BOARD_PART_1, BOARD_PART_2, data::iblength, X_POS, and Y_POS.

Referenced by options().

00026 {
00027     int ii;
00028     int ik;
00029     int iletter=65;
00030     int inumber=d1->iblength;
00031     
00032     for (ii=0;ii<d1->iblength;ii++)                   //print chessboard
00033     {
00034         for (ik=0;ik<d1->iblength;ik++)
00035         {
00036             if((ii+ik)%2)
00037             {
00038                 gotoxy(ii+X_POS,ik+Y_POS);   
00039                 printf("%c",BOARD_PART_1);               
00040             }
00041             else
00042             {
00043                 gotoxy(ii+X_POS,ik+Y_POS);   
00044                 printf("%c",BOARD_PART_2);
00045             }       
00046         }
00047     }
00048     for (ik=0;ik<d1->iblength;ik++)                   //print frame around chessboard
00049     {   
00050         gotoxy(ik+X_POS,Y_POS-1);
00051         printf("%c",205);                             //horizontal upper frame
00052         
00053         gotoxy(X_POS-1,Y_POS+ik);
00054         printf("%c",186);                             //vertical left frame
00055         
00056         gotoxy(ik+X_POS,Y_POS+d1->iblength);
00057         printf("%c",205);                             //horizontal lower frame
00058         
00059         gotoxy(d1->iblength+X_POS,Y_POS+ik);
00060         printf("%c",186);                             //vertical right frame
00061     
00062         gotoxy(ik+X_POS,Y_POS+d1->iblength+1);        //Letters
00063         printf("%c",iletter);
00064         
00065         gotoxy(X_POS+d1->iblength+1,Y_POS+ik);
00066         printf("%d",inumber);                         //Numbers
00067         
00068         iletter++;
00069         inumber--;
00070     }        
00071     gotoxy(X_POS-1,Y_POS-1);
00072     printf("%c",201);                                 //frame corner left upper
00073     gotoxy(X_POS+d1->iblength,Y_POS-1);               
00074     printf("%c",187);                                 //frame corner right upper
00075     gotoxy(X_POS-1,Y_POS+d1->iblength);
00076     printf("%c",200);                                 //frame corner left lower
00077     gotoxy(X_POS+d1->iblength,Y_POS+d1->iblength);
00078     printf("%c",188);                                 //frame corner right lower
00079 }


Generated on Sun Dec 18 19:26:14 2005 for n-Queens Problem by  doxygen 1.4.5